home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / GCC / GNU / lib / gcc-lib / amigados / 2.6.3 / include / curses.h next >
Encoding:
C/C++ Source or Header  |  1995-03-30  |  12.5 KB  |  346 lines

  1. /*
  2.  * Copyright (c) 1981, 1993
  3.  *    The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)curses.h    8.2 (Berkeley) 1/2/94
  34.  */
  35.  
  36. #ifndef _CURSES_H_
  37. #define    _CURSES_H_
  38.  
  39. #include <stdio.h>
  40. #include <sys/types.h>
  41.  
  42. /*
  43.  * The following #defines and #includes are present for backward
  44.  * compatibility only.  They should not be used in future code.
  45.  *
  46.  * START BACKWARD COMPATIBILITY ONLY.
  47.  */
  48. #ifndef _CURSES_PRIVATE
  49. #define    bool    char
  50. #define    reg    register
  51.  
  52. #ifndef TRUE
  53. #define    TRUE    (1)
  54. #endif
  55. #ifndef FALSE
  56. #define    FALSE    (0)
  57. #endif
  58.  
  59. #define    _puts(s)    tputs(s, 0, __cputchar)
  60. #define    _putchar(c)    __cputchar(c)
  61.  
  62. /* Old-style terminal modes access. */
  63. #define    baudrate()    (cfgetospeed(&__baset))
  64. #define    crmode()    cbreak()
  65. #define    erasechar()    (__baset.c_cc[VERASE])
  66. #define    killchar()    (__baset.c_cc[VKILL])
  67. #define    nocrmode()    nocbreak()
  68. #define    ospeed        (cfgetospeed(&__baset))
  69. #endif /* _CURSES_PRIVATE */
  70.  
  71. extern char     GT;            /* Gtty indicates tabs. */
  72. extern char     NONL;            /* Term can't hack LF doing a CR. */
  73. extern char     UPPERCASE;        /* Terminal is uppercase only. */
  74.  
  75. extern int     My_term;        /* Use Def_term regardless. */
  76. extern char    *Def_term;        /* Default terminal type. */
  77.  
  78. /* Termcap capabilities. */
  79. extern char    AM, BS, CA, DA, EO, HC, IN, MI, MS, NC, NS, OS,
  80.         PC, UL, XB, XN, XT, XS, XX;
  81. extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  82.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  83.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  84.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  85.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  86.         *VE, *al, *dl, *sf, *sr,
  87.         *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
  88.         *RIGHT_PARM;
  89.  
  90. /* END BACKWARD COMPATIBILITY ONLY. */
  91.  
  92. /* 8-bit ASCII characters. */
  93. #define    unctrl(c)        __unctrl[(c) & 0xff]
  94. #define    unctrllen(ch)        __unctrllen[(ch) & 0xff]
  95.  
  96. extern char    *__unctrl[256];    /* Control strings. */
  97. extern char     __unctrllen[256];    /* Control strings length. */
  98.  
  99. /*
  100.  * A window an array of __LINE structures pointed to by the 'lines' pointer.
  101.  * A line is an array of __LDATA structures pointed to by the 'line' pointer.
  102.  *
  103.  * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new
  104.  * fields are added -- padding fields with *constant values* should ensure 
  105.  * that the compiler will not generate any padding when storing an array of
  106.  *  __LDATA structures.  This is to enable consistent use of memcmp, and memcpy
  107.  * for comparing and copying arrays.
  108.  */
  109. typedef struct {
  110.     char ch;            /* the actual character */
  111.  
  112. #define    __STANDOUT    0x01          /* Added characters are standout. */
  113.     char attr;            /* attributes of character */
  114. } __LDATA;
  115.  
  116. #define __LDATASIZE    (sizeof(__LDATA))
  117.  
  118. typedef struct {
  119. #define    __ISDIRTY    0x01        /* Line is dirty. */
  120. #define __ISPASTEOL    0x02        /* Cursor is past end of line */
  121. #define __FORCEPAINT    0x04        /* Force a repaint of the line */
  122.     u_int flags;
  123.     u_int hash;            /* Hash value for the line. */
  124.     size_t *firstchp, *lastchp;    /* First and last chngd columns ptrs */
  125.     size_t firstch, lastch;        /* First and last changed columns. */
  126.     __LDATA *line;            /* Pointer to the line text. */
  127. } __LINE;
  128.  
  129. typedef struct __window {        /* Window structure. */
  130.     struct __window    *nextp, *orig;    /* Subwindows list and parent. */
  131.     size_t begy, begx;        /* Window home. */
  132.     size_t cury, curx;        /* Current x, y coordinates. */
  133.     size_t maxy, maxx;        /* Maximum values for curx, cury. */
  134.     short ch_off;            /* x offset for firstch/lastch. */
  135.     __LINE **lines;            /* Array of pointers to the lines */
  136.     __LINE  *lspace;        /* line space (for cleanup) */
  137.     __LDATA *wspace;        /* window space (for cleanup) */
  138.  
  139. #define    __ENDLINE    0x001        /* End of screen. */
  140. #define    __FLUSH        0x002        /* Fflush(stdout) after refresh. */
  141. #define    __FULLLINE    0x004        /* Line width = terminal width. */
  142. #define    __FULLWIN    0x008        /* Window is a screen. */
  143. #define    __IDLINE    0x010        /* Insert/delete sequences. */
  144. #define    __SCROLLWIN    0x020        /* Last char will scroll window. */
  145. #define    __SCROLLOK    0x040        /* Scrolling ok. */
  146. #define    __CLEAROK    0x080        /* Clear on next refresh. */
  147. #define __WSTANDOUT    0x100        /* Standout window */
  148. #define __LEAVEOK    0x200        /* If curser left */    
  149.     u_int flags;
  150. } WINDOW;
  151.  
  152. /* Curses external declarations. */
  153. extern WINDOW    *curscr;        /* Current screen. */
  154. extern WINDOW    *stdscr;        /* Standard screen. */
  155.  
  156. extern struct termios __orig_termios;    /* Terminal state before curses */
  157. extern struct termios __baset;        /* Our base terminal state */
  158. extern int __tcaction;            /* If terminal hardware set. */
  159.  
  160. extern int     COLS;            /* Columns on the screen. */
  161. extern int     LINES;            /* Lines on the screen. */
  162.  
  163. extern char    *ttytype;        /* Full name of current terminal. */
  164.  
  165. #define    ERR    (0)            /* Error return. */
  166. #define    OK    (1)            /* Success return. */
  167.  
  168. /* Standard screen pseudo functions. */
  169. #define    addbytes(s, n)            __waddbytes(stdscr, s, n, 0)
  170. #define    addch(ch)            waddch(stdscr, ch)
  171. #define    addnstr(s, n)            waddnstr(stdscr, s, n)
  172. #define    addstr(s)            __waddbytes(stdscr, s, strlen(s), 0)
  173. #define    clear()                wclear(stdscr)
  174. #define    clrtobot()            wclrtobot(stdscr)
  175. #define    clrtoeol()            wclrtoeol(stdscr)
  176. #define    delch()                wdelch(stdscr)
  177. #define    deleteln()            wdeleteln(stdscr)
  178. #define    erase()                werase(stdscr)
  179. #define    getch()                wgetch(stdscr)
  180. #define    getstr(s)            wgetstr(stdscr, s)
  181. #define    inch()                winch(stdscr)
  182. #define    insch(ch)            winsch(stdscr, ch)
  183. #define    insertln()            winsertln(stdscr)
  184. #define    move(y, x)            wmove(stdscr, y, x)
  185. #define    refresh()            wrefresh(stdscr)
  186. #define    standend()            wstandend(stdscr)
  187. #define    standout()            wstandout(stdscr)
  188. #define    waddbytes(w, s, n)        __waddbytes(w, s, n, 0)
  189. #define    waddstr(w, s)            __waddbytes(w, s, strlen(s), 0)
  190.  
  191. /* Standard screen plus movement pseudo functions. */
  192. #define    mvaddbytes(y, x, s, n)        mvwaddbytes(stdscr, y, x, s, n)
  193. #define    mvaddch(y, x, ch)        mvwaddch(stdscr, y, x, ch)
  194. #define    mvaddnstr(y, x, s, n)        mvwaddnstr(stdscr, y, x, s, n)
  195. #define    mvaddstr(y, x, s)        mvwaddstr(stdscr, y, x, s)
  196. #define    mvdelch(y, x)            mvwdelch(stdscr, y, x)
  197. #define    mvgetch(y, x)            mvwgetch(stdscr, y, x)
  198. #define    mvgetstr(y, x, s)        mvwgetstr(stdscr, y, x, s)
  199. #define    mvinch(y, x)            mvwinch(stdscr, y, x)
  200. #define    mvinsch(y, x, c)        mvwinsch(stdscr, y, x, c)
  201. #define    mvwaddbytes(w, y, x, s, n) \
  202.     (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0))
  203. #define    mvwaddch(w, y, x, ch) \
  204.     (wmove(w, y, x) == ERR ? ERR : waddch(w, ch))
  205. #define    mvwaddnstr(w, y, x, s, n) \
  206.     (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n))
  207. #define    mvwaddstr(w, y, x, s) \
  208.     (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0))
  209. #define    mvwdelch(w, y, x) \
  210.     (wmove(w, y, x) == ERR ? ERR : wdelch(w))
  211. #define    mvwgetch(w, y, x) \
  212.     (wmove(w, y, x) == ERR ? ERR : wgetch(w))
  213. #define    mvwgetstr(w, y, x, s) \
  214.     (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s))
  215. #define    mvwinch(w, y, x) \
  216.     (wmove(w, y, x) == ERR ? ERR : winch(w))
  217. #define    mvwinsch(w, y, x, c) \
  218.     (wmove(w, y, x) == ERR ? ERR : winsch(w, c))
  219.  
  220. /* Psuedo functions. */
  221. #define    clearok(w, bf) \
  222.     ((bf) ? ((w)->flags |= __CLEAROK) : ((w)->flags &= ~__CLEAROK))
  223. #define    flushok(w, bf) \
  224.     ((bf) ? ((w)->flags |= __FLUSH) : ((w)->flags &= ~__FLUSH))
  225. #define    getyx(w, y, x) \
  226.     (y) = (w)->cury, (x) = (w)->curx
  227. #define    leaveok(w, bf) \
  228.     ((bf) ? ((w)->flags |= __LEAVEOK) : ((w)->flags &= ~__LEAVEOK))
  229. #define    scrollok(w, bf) \
  230.     ((bf) ? ((w)->flags |= __SCROLLOK) : ((w)->flags &= ~__SCROLLOK))
  231. #define    winch(w) \
  232.     ((w)->lines[(w)->cury]->line[(w)->curx].ch & 0177)
  233.  
  234. /* Public function prototypes. */
  235. int     box __P((WINDOW *, int, int));
  236. int     cbreak __P((void));
  237. int     delwin __P((WINDOW *));
  238. int     echo __P((void));
  239. int     endwin __P((void));
  240. char    *fullname __P((char *, char *));
  241. char    *getcap __P((char *));
  242. int     gettmode __P((void));
  243. void     idlok __P((WINDOW *, int));
  244. WINDOW    *initscr __P((void));
  245. char    *longname __P((char *, char *));
  246. int     mvcur __P((int, int, int, int));
  247. int     mvprintw __P((int, int, const char *, ...));
  248. int     mvscanw __P((int, int, const char *, ...));
  249. int     mvwin __P((WINDOW *, int, int));
  250. int     mvwprintw __P((WINDOW *, int, int, const char *, ...));
  251. int     mvwscanw __P((WINDOW *, int, int, const char *, ...));
  252. WINDOW    *newwin __P((int, int, int, int));
  253. int     nl __P((void));
  254. int     nocbreak __P((void));
  255. int     noecho __P((void));
  256. int     nonl __P((void));
  257. int     noraw __P((void));
  258. int     overlay __P((WINDOW *, WINDOW *));
  259. int     overwrite __P((WINDOW *, WINDOW *));
  260. int     printw __P((const char *, ...));
  261. int     raw __P((void));
  262. int     resetty __P((void));
  263. int     savetty __P((void));
  264. int     scanw __P((const char *, ...));
  265. int     scroll __P((WINDOW *));
  266. int     setterm __P((char *));
  267. int     sscans __P((WINDOW *, const char *, ...));
  268. WINDOW    *subwin __P((WINDOW *, int, int, int, int));
  269. int     suspendwin __P((void));
  270. int     touchline __P((WINDOW *, int, int, int));
  271. int     touchoverlap __P((WINDOW *, WINDOW *));
  272. int     touchwin __P((WINDOW *));
  273. #if 0    /* FIXME */
  274. int      vwprintw __P((WINDOW *, const char *, _VA_LIST_));
  275. int      vwscanw __P((WINDOW *, const char *, _VA_LIST_));
  276. #endif
  277. int     waddch __P((WINDOW *, int));
  278. int     waddnstr __P((WINDOW *, const char *, int));
  279. int     wclear __P((WINDOW *));
  280. int     wclrtobot __P((WINDOW *));
  281. int     wclrtoeol __P((WINDOW *));
  282. int     wdelch __P((WINDOW *));
  283. int     wdeleteln __P((WINDOW *));
  284. int     werase __P((WINDOW *));
  285. int     wgetch __P((WINDOW *));
  286. int     wgetstr __P((WINDOW *, char *));
  287. int     winsch __P((WINDOW *, int));
  288. int     winsertln __P((WINDOW *));
  289. int     wmove __P((WINDOW *, int, int));
  290. int     wprintw __P((WINDOW *, const char *, ...));
  291. int     wrefresh __P((WINDOW *));
  292. int     wscanw __P((WINDOW *, const char *, ...));
  293. char    *wstandend __P((WINDOW *));
  294. char    *wstandout __P((WINDOW *));
  295. #if 0    /* FIXME */
  296. int     vwprintw __P((WINDOW *, const char *, _VA_LIST_));
  297. #endif
  298.  
  299. /* Private functions that are needed for user programs prototypes. */
  300. void     __cputchar __P((int));
  301. int     __waddbytes __P((WINDOW *, const char *, int, int));
  302.  
  303. /* Private functions. */
  304. #ifdef _CURSES_PRIVATE
  305. #include <dbug.h>
  306. void     __CTRACE __P((const char *, ...));
  307. u_int     __hash __P((char *, int));
  308. void     __id_subwins __P((WINDOW *));
  309. int     __mvcur __P((int, int, int, int, int));
  310. void     __restore_stophandler __P((void));
  311. void     __set_stophandler __P((void));
  312. void     __set_subwin __P((WINDOW *, WINDOW *));
  313. void     __startwin __P((void));
  314. void     __stop_signal_handler __P((int));
  315. void     __swflags __P((WINDOW *));
  316. int     __touchline __P((WINDOW *, int, int, int, int));
  317. int     __touchwin __P((WINDOW *));
  318. char    *__tscroll __P((const char *, int));
  319. int     __waddch __P((WINDOW *, __LDATA *));
  320.  
  321. /* Private #defines. */
  322. #define    min(a,b)    ((a) < (b) ? (a) : (b))
  323. #define    max(a,b)    ((a) > (b) ? (a) : (b))
  324.  
  325. /* Private externs. */
  326. extern int     __echoit;
  327. extern int     __endwin;
  328. extern int     __pfast;
  329. extern int     __rawmode;
  330. extern int     __noqch;
  331. #endif
  332.  
  333. /* Termcap functions. */
  334. int     tgetent __P((char *, char *));
  335. int     tgetnum __P((char *));
  336. int     tgetflag __P((char *));
  337. char    *tgetstr __P((char *, char **));
  338. char    *tgoto __P((char *, int, int));
  339. int     tputs __P((char *, int, void (*)(int)));
  340.  
  341. #if defined(__cplusplus) || defined(__USE_FIXED_PROTOTYPES__)
  342. extern int getcurx (WINDOW *);
  343. extern int getcury (WINDOW *);
  344. #endif /* defined(__cplusplus) || defined(__USE_FIXED_PROTOTYPES__*/
  345. #endif /* !_CURSES_H_ */
  346.